{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2. Linear algebra\n",
    "\n",
    "This chapter is devoted to linear algebra and its translation to Dirac's notation. The importance of linear algebra for quantum computing comes from the fact that quantum mechanics, the theory which describes the physical world, can be formulated in matrix representations. This means that the state of a physical systems can be represented as a vector in a particular vector space (a Hilbert space) and to each property of the system in the physical world there correspond a matrix (operators) in the vector space. The time evolution of a state (vector), or its properties, are then extracted by acting with the corresponding operator (matrix) on the state. Thus, it is fundamental to have a basic understanding of linear algebra and its rules. \n",
    "To simplify the vector and matrix notations typical of linear algebra, we introduce Dirac's notation. This allows to write the state of a system as a vector in the vector space in a compact way. The basics of linear algebra for Hilbert spaces in terms of both Dirac's notation and matrix representation are then reviewed. Finally, operators are discussed in detail.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.1 States\n",
    "\n",
    "A physical system is a part of the physical world which we wish to investigate. Thus, a physical system can be seen as a specific physical object, like an atom or a cat, or a more complicated entity, such as the atmosphere of the earth, separated from the rest of the natural world. Certain properties can be chosen to describe the state of a physical system at any given time. The values of these properties determine the specific state of the system. If these values change, the state of the system will also change. \n",
    "\n",
    "\n",
    "### Vector space $\\mathcal{H}$\n",
    "\n",
    "In quantum mechanics, a physical system has a mathematical representation in terms of a complex vector space, also called a Hilbert space $\\mathcal{H}$. The characteristics of this vector space, like its dimensions, are determined by the properties chosen for the description of the state of the physical system. If one selects $n$ independent properties to describe a system, the vector space representing this system will have dimension $n$. A specific state of the system, or a specific set of values of the chosen properties of the system, is represented by a vector in the Hilbert space. We adopt Dirac's notation to denote vectors, thus a vector $\\vec{A}$ will be written as a \"ket\" vector $\\lvert A \\rangle$. Multiples of a vector describing a certain state, like $5\\lvert A \\rangle$ or $25i\\lvert A \\rangle$, will still describe the same state of the system. Thus, each state has an infinite number of ket vectors associated to it.\n",
    "\n",
    "\n",
    "<img src=\"figures/2/hilbert_space1.jpeg\"  width=\"400\">\n",
    "$$\\text{1. Pictorial representation of a $n$ dimensional Hilbert space. The $n$ basis vectors $\\lvert e_i \\rangle$  are all orthogonal to each other. The state of a system $\\lvert \\psi \\rangle$ is a vector in the Hilbert space.}$$\n",
    "\n",
    "In linear algebra, a vector in an $n$ dimensional space can be represented as an array with $n$ entries in a column\n",
    "\n",
    "$$\n",
    " \\lvert A \\rangle = \n",
    "        \\begin{pmatrix}\n",
    "        a_1 \\\\\n",
    "        a_2 \\\\\n",
    "        . \\\\\n",
    "        . \\\\\n",
    "        . \\\\\n",
    "        a_n \n",
    "        \\end{pmatrix} \n",
    "$$\n",
    "\n",
    "\n",
    "### Adjoint space $\\mathcal{H}^{\\ast}$\n",
    "\n",
    "We can imagine a vector space, the adjoint space $\\mathcal{H}^{\\ast}$, whose elements $\\langle A \\rvert$, called bra vectors, are in one-to-one correspondance with the vector space $\\mathcal{H}$. For each element $\\lvert A \\rangle$ of the vector space, there is a corresponding element $\\langle A \\rvert$ in the adjoint space.\n",
    "\n",
    "In matrix representation, to find the adjoint ($\\dagger$) of a matrix we take the complex conjugate ($\\ast$) of the entries and then transpose ($T$) the matrix \n",
    "\n",
    "$$\n",
    "\\begin{pmatrix}\n",
    "        a_{11} & a_{12} & ... & a_{1n} \\\\\n",
    "        a_{21} & a_{22} & ... & a_{2n} \\\\\n",
    "        . & . & ... & . \\\\\n",
    "        . & . & ... & . \\\\\n",
    "        . & . & ... & . \\\\\n",
    "        a_{n1} & a_{n2} & ... & a_{nn} \n",
    "        \\end{pmatrix}^{\\dagger} = \n",
    "        \\begin{pmatrix}\n",
    "        a_{11}^{*} & a_{12}^{*} & ... & a_{1n}^{*} \\\\\n",
    "        a_{21}^{*} & a_{22}^{*} & ... & a_{2n}^{*} \\\\\n",
    "        . & . & ... & . \\\\\n",
    "        . & . & ... & . \\\\\n",
    "        . & . & ... & . \\\\\n",
    "        a_{n1}^{*} & a_{n2}^{*} & ... & a_{nn}^{*} \n",
    "        \\end{pmatrix}^{T} =\n",
    "        \\begin{pmatrix}\n",
    "        a_{11}^{*} & a_{21}^{*} & ... & a_{n1}^{*} \\\\\n",
    "        a_{12}^{*} & a_{22}^{*} & ... & a_{n2}^{*} \\\\\n",
    "        . & . & ... & . \\\\\n",
    "        . & . & ... & . \\\\\n",
    "        . & . & ... & . \\\\\n",
    "        a_{1n}^{*} & a_{2n}^{*} & ... & a_{nn}^{*} \n",
    "        \\end{pmatrix}       \n",
    "$$\n",
    "\n",
    "For vectors we have\n",
    "\n",
    "$$\n",
    "\\begin{pmatrix}\n",
    "        a_{1} \\\\\n",
    "        a_{2}  \\\\\n",
    "        .  \\\\\n",
    "        .\\\\\n",
    "        . \\\\\n",
    "        a_{n} \n",
    "        \\end{pmatrix}^{\\dagger} = \n",
    "        \\begin{pmatrix}\n",
    "        a_{1}^{*} & a_{2}^{*} & ... & a_{n}^{*}\n",
    "        \\end{pmatrix}\n",
    "$$\n",
    "\n",
    "In Dirac's notation, the adjoint of a ket vector  $\\lvert  A  \\rangle $ is the corresponding bra vector $\\langle A \\rvert$: $\\langle A \\rvert = \\lvert  A  \\rangle^{\\dagger} $.\n",
    "Thus bra vector correspond to row vectors in matrix representation.\n",
    "\n",
    "\n",
    "\n",
    "### Scalar product\n",
    "\n",
    "Given vectors and their adjoint, one can define a scalar product on the Hilbert space. \n",
    "The scalar product is a complex number associated with a bra-ket pair. The scalar product of the vector $\\left\\vert A\\right\\rangle \\in \\mathcal{H}$ with the vector $\\left\\vert\n",
    "B\\right\\rangle \\in \\mathcal{H}$ is defined as\n",
    "\n",
    "\n",
    "\\begin{equation}\n",
    "\\left\\langle A\\right\\vert B\\rangle = c \n",
    "\\end{equation}\n",
    "\n",
    "where $c$ a complex number. In the matrix representation, the scalar product is calculated by summing the products of corresponding entries\n",
    "\n",
    "\n",
    "\\begin{eqnarray}\n",
    "\\left\\langle A\\right\\vert B\\rangle &=&\\left( \n",
    "\\begin{array}{c}\n",
    "a_{1} \\\\ \n",
    "a_{2} \\\\ \n",
    ". \\\\ \n",
    ". \\\\ \n",
    ". \\\\ \n",
    "a_{n-1} \\\\ \n",
    "a_{n}%\n",
    "\\end{array}\n",
    "\\right) \\cdot \\left( \n",
    "\\begin{array}{c}\n",
    "b_{1} \\\\ \n",
    "b_{2} \\\\ \n",
    ". \\\\ \n",
    ". \\\\ \n",
    ". \\\\ \n",
    "b_{n-1} \\\\ \n",
    "b_{n}%\n",
    "\\end{array}\n",
    "\\right)\n",
    "=\\left( \n",
    "\\begin{array}{ccccccc}\n",
    "a_{1}^{\\ast } & a_{2}^{\\ast } & . & . & . & a_{n-1}^{\\ast } & a_{n}^{\\ast }%\n",
    "\\end{array}%\n",
    "\\right) \\left( \n",
    "\\begin{array}{c}\n",
    "b_{1} \\\\ \n",
    "b_{2} \\\\ \n",
    ". \\\\ \n",
    ". \\\\ \n",
    ". \\\\ \n",
    "b_{n-1} \\\\ \n",
    "b_{n}%\n",
    "\\end{array}%\n",
    "\\right) =\\sum_{i=1}^{n}a_{i}^{\\ast }b_{i}\n",
    "\\end{eqnarray}\n",
    "\n",
    "\n",
    "We say that $\\left\\vert A\\right\\rangle $ and $\\left\\vert B\\right\\rangle $\n",
    "are orthogonal if\n",
    "\n",
    "\\begin{equation}\n",
    "\\left\\langle A\\right\\vert B\\rangle =0.  \n",
    "\\end{equation}\n",
    "\n",
    "$\\left\\vert A\\right\\rangle $ is normalized if\n",
    "\n",
    "\\begin{equation}\n",
    "\\left\\langle A\\right\\vert A\\rangle =1.\n",
    "\\end{equation}\n",
    "\n",
    "Putting these two properties together, we say that two states $\\left\\vert A\\right\\rangle $ and $\\left\\vert B\\right\\rangle $ are orthonormal if\n",
    "\n",
    "\\begin{equation}\n",
    "\\left\\langle A\\right\\vert B\\rangle =\\delta _{AB},  \n",
    "\\end{equation}\n",
    "\n",
    "where $\\delta _{AB}$ is the Kronecker symbol, which is equal to one if $A=B$ and zero otherwise.\n",
    "\n",
    "\n",
    "### Basis\n",
    "\n",
    "Let's say that a set of $n$ vectors $\\left\\{ \\left\\vert\n",
    "e_{n}\\right\\rangle \\right\\} \\subseteq \\mathcal{H}$ forms an orthonormal\n",
    "basis for $\\mathcal{H}$. Thus, $\\left\\langle e_{n}\\right\\vert e_{m}\\rangle\n",
    "=\\delta _{nm}$. Every vector $\\left\\vert B\\right\\rangle $ from the Hilbert space $\\left\\vert B\\right\\rangle \\in \\mathcal{H}$ may be expanded in terms of this\n",
    "orthonormal basis as\n",
    "\n",
    "\\begin{equation}\n",
    "\\left\\vert B\\right\\rangle =\\sum_{i=1}^{n}b_{i}\\left\\vert e_{i}\\right\\rangle .\n",
    "\\end{equation}\n",
    "\n",
    "The coefficients $b_{i}=\\left\\langle B\\right\\vert e_{i}\\rangle $ are the projections of $\\left\\vert B\\right\\rangle $ with respect to the basis $\\left\\{ \\left\\vert e_{n}\\right\\rangle\n",
    "\\right\\}$.\n",
    "\n",
    "If $\\left\\{ \\left\\vert e_{n}\\right\\rangle \\right\\} \\subseteq \\mathcal{H}$ form an orthonormal\n",
    "basis for $\\mathcal{H}$ then $\\left\\{ \\left\\langle e_{n}\\right\\vert \\right\\} \n",
    "$ is an orthonormal basis for the adjoint space $\\mathcal{H}^{\\ast }$.\n",
    "\n",
    "\n",
    "\n",
    "### Tensor product\n",
    "\n",
    "One can consider the tensor product between two Hilbert spaces $\\mathcal{H}_A\\otimes \\mathcal{H}_B$. The basis for the new vector space obtained in this way is given by the tensor product of the bases of the two spaces.\n",
    "\n",
    "In general, the tensor product of any two vectors can be written in matrix form as\n",
    "\n",
    "\\begin{equation*}\n",
    "\\left( \n",
    "\\begin{array}{c}\n",
    "a_0 \\\\ \n",
    "a_1 \\\\\n",
    ". \\\\\n",
    ". \\\\\n",
    ". \\\\\n",
    "a_n\n",
    "\\end{array}\n",
    "\\right) \\otimes \\left( \n",
    "\\begin{array}{c}\n",
    "b_0 \\\\ \n",
    "b_1\\\\\n",
    ". \\\\\n",
    ". \\\\\n",
    ". \\\\\n",
    "b_n\n",
    "\\end{array}\n",
    "\\right) = \\left( \n",
    "\\begin{array}{c}\n",
    "a_0b_0 \\\\ \n",
    "a_0b_1 \\\\ \n",
    ". \\\\\n",
    ". \\\\\n",
    ". \\\\\n",
    "a_0b_n \\\\ \n",
    ". \\\\\n",
    ". \\\\\n",
    ". \\\\\n",
    "a_nb_0 \\\\ \n",
    "a_nb_1 \\\\ \n",
    ". \\\\\n",
    ". \\\\\n",
    ". \\\\\n",
    "a_nb_n \\\\\n",
    "\\end{array}\n",
    "\\right)\n",
    "\\end{equation*}\n",
    "\n",
    "In Dirac's notation, the tensor product between two vectors is simply written as\n",
    "\n",
    "$$ \\lvert A \\rangle \\otimes \\lvert B \\rangle = \\lvert A \\rangle \\lvert B \\rangle = \\lvert A , B \\rangle = \\lvert A B \\rangle $$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.2 Operators\n",
    "\n",
    "Operators are associated to physical properties of the system. More specifically, to find out the value of a property of the system, we \"act\" with the operator on the state of the system. The result of the operation encodes the value of the physical property associated to the operator for the system in a certain state.\n",
    "\n",
    "<img src=\"figures/2/operator2.jpeg\"  width=\"700\">\n",
    "$$\\text{2. In general, the effect of an operator $\\hat{O}$ acting on a state $\\lvert \\psi \\rangle$ is to rotate the vector corresponding to the state. Therefore, giving a new state $\\lvert \\psi' \\rangle$. }$$\n",
    "\n",
    "\n",
    "Operators can be written in Dirac's notation as ket-bra pairs $\\lvert A\\rangle \\langle A\\rvert$, this is called an outer product. By writing an operator in this way, one can immediately see that when an operator acts on a state, this extracts the contribution of the state to the operator: $\\lvert A\\rangle \\langle A\\rvert \\lvert B \\rangle = \\langle A \\lvert B \\rangle \\lvert A\\rangle $.\n",
    "\n",
    "\n",
    "In general, operators are denoted by a hat, therefore the operator associated with the outer product $\\lvert A\\rangle \\langle A\\rvert$ of the system is written as $\\hat{A}$. A generic operator $\\hat{O}$ can always be written in terms of a combination of outer products of the basis vectors of the Hilbert space\n",
    "\n",
    "\\begin{equation}\n",
    "\\hat{O}=\\sum_{i,j=1}^{n}O_{ij}\\lvert\n",
    "b_{i}\\rangle \\langle b_{j}\\rvert . \n",
    "\\end{equation}\n",
    "\n",
    "\n",
    "where $O_{ij}=\\langle b_{i}\\rvert \\hat{O} \\lvert b_{j} \\rangle $ are the matrix element and $\\left\\{\n",
    "\\lvert b_{n}\\rangle \\right\\} $ is an orthonormal basis for the $n$ dimensional\n",
    "vector space $\\mathcal{H}$. In other words, any linear operator can be\n",
    "written as combination of all the possible outer products of the basis vectors $\\lvert b_{i}\\rangle \\langle b_{j}\\rvert $.\n",
    "\n",
    "\n",
    "We have seen how operators can be written in terms of outer products of ket-bra vectors, in linear algebra terms an operator is a linear transformation on the Hilbert space. Recall that a linear transformation maps vectors in $\\mathcal{H}$ to vectors in $\\mathcal{H}$ and is written a sa matrix. To see this, let us see the matrix form of an operator\n",
    "\n",
    "\n",
    "\\begin{equation*}\n",
    "\\hat{O} = \\left( \n",
    "\\begin{array}{cccccc}\n",
    "O_{11} & O_{12} & . & . & O_{1,N-1} & O_{1N} \\\\ \n",
    "O_{21} & O_{22} & . & . & . & . \\\\ \n",
    ". & . & . & . & . & . \\\\ \n",
    ". & . & . & . & . & . \\\\ \n",
    "O_{N1} & O_{N2} & . & . & O_{N,N-1} & O_{NN} \\\\ \n",
    "&  &  &  &  & \n",
    "\\end{array}\n",
    "\\right)\n",
    "\\end{equation*}\n",
    "\n",
    "\n",
    "In the matrix representation of the operator $\\hat{O}$, $O_{ij}$ is the matrix element in the $i^{th}$ row and $j^{th}$ column. \n",
    "The action of the operator $\\hat{O}$ on a vector $\\lvert\n",
    "A \\rangle $ is then written as\n",
    "\n",
    "\\begin{equation}\n",
    "\\hat{O}\\lvert A\\rangle =\\sum_{i,j=1}^{n} O_{ij}\\lvert b_{i} \\rangle \\langle b_{j}\\rvert\n",
    "A\\rangle =\\sum_{i,j=1}^{n} O_{ij} \\langle b_{j} \\rvert A \\rangle \\vert b_{i} \\rangle = \\sum_{i,j = 1}^{n} O_{ij} A_j  \\lvert b_i  \\rangle .\n",
    "\\end{equation}\n",
    "\n",
    "\n",
    "where $A_j$ is defined as $\\langle b_j  \\lvert  A  \\rangle $, the component of $ \\lvert  A  \\rangle $ along  $\\lvert  b_j  \\rangle $ .\n",
    "\n",
    "\n",
    "\n",
    "### Properties\n",
    "\n",
    "#### Linear\n",
    "\n",
    "Operators are linear:\n",
    "\n",
    "\\begin{equation}\n",
    "\\hat{O}(c_{1}\\lvert A\\rangle +c_{2}\\lvert\n",
    "B\\rangle )=c_{1}\\hat{O}\\lvert A\\rangle\n",
    "+c_{2}\\hat{O}\\lvert B\\rangle . \n",
    "\\end{equation}\n",
    "\n",
    "#### Hermitean\n",
    "\n",
    "Observables quantities in quantum mechanics are represented by Hermitean operators. Suppose that $\\hat{O}$ is an operator on $\\mathcal{H}$. The adjoint operator of $\\hat{O}$ is denoted by $\\hat{O}^{\\dagger }$ and it is defined as a linear operator on $\\mathcal{H}^{\\ast }$ that satisfies the following condition:\n",
    "\n",
    "\\begin{equation}\n",
    "\\left( \\langle A \\rvert \\hat{O}^{\\dagger} \\lvert B \\rangle \\right) ^{\\dagger} = \\langle B \\rvert \\hat{O} \\lvert A \\rangle \n",
    "\\end{equation}\n",
    "\n",
    "That is, Hermitean operators satisfy: $\\hat{O}=\\hat{O}^{\\dagger}$.\n",
    "\n",
    "\n",
    "#### Unitary\n",
    "\n",
    "An operator $\\hat{U}^{-1}$ is the inverse of the operator $\\hat{U}$ if $\\hat{U}^{-1}\\hat{U}=\\hat{I},$ where $\\hat{I}$\n",
    "is the identity operator. Also, an operator $\\hat{U}$ is unitary if $\\hat{U}^{\\dagger}=\\hat{U}^{-1}$ so that $\\hat{U}^{\\dagger}\\hat{U} = \\hat{I}$ .\n",
    "Note that unitary operators can be formed by exponentiating Hermitean operators $\\hat{U} = e^{i\\hat{O}}$, so that\n",
    "\n",
    "\n",
    "$$ \\hat{U}^{\\dagger} \\hat{U}= e^{-i\\hat{O}^{\\dagger}} e^{i\\hat{O}} = e^{-i\\left( \\hat{O}^{\\dagger}-\\hat{O}\\right)} =  \\hat{I} $$\n",
    "\n",
    "since $\\hat{O}^{\\dagger}-\\hat{O}=0$ if $\\hat{O}$ is Hermitean.\n",
    "\n",
    "Time evolution operators in quantum mechanics are unitary.\n",
    "\n",
    "\n",
    "\n",
    "### Expectation value\n",
    "\n",
    "The value of the physical quantity corresponding to the operator $\\hat{O}$ for the system in a state $\\lvert A\\rangle $ is called the expectation value $\\langle \\hat{O} \\rangle$ of $\\hat{O}$. This is calculated as\n",
    "\n",
    "\\begin{equation}\n",
    "\\langle \\hat{O} \\rangle =\\langle\n",
    "A\\rvert \\hat{O} \\lvert A \\rangle = c \\; \\text{ (a\n",
    "number)}.  \n",
    "\\end{equation}\n",
    "\n",
    "\n",
    "The expectation value of an Hermitian operator is real:\n",
    "\n",
    "\\begin{equation}\n",
    "\\langle \\hat{O}\\rangle ^{\\ast }=\\left( \\langle A\\rvert \\hat{O}\\lvert A\\rangle\n",
    "\\right) ^{\\ast }=\\left( \\langle A\\rvert \\hat{O}^{\\dagger }\\lvert A\\rangle \\right) =\\langle A\\rvert \n",
    "\\hat{O}\\lvert A\\rangle =\\langle \\hat{O}\\rangle \n",
    "\\end{equation}\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "### Eigenstate and eigenvalues\n",
    "\n",
    "A vector $\\lvert A \\rangle $ is an eigenvector of an operator $\\hat{O}$ if\n",
    "\n",
    "\\begin{equation}\n",
    "\\hat{O} \\lvert A \\rangle =a \\lvert A\\rangle\n",
    "\\end{equation}\n",
    "\n",
    "where $a$ is a constant and is called the eigenvalue of $\\hat{O}$\n",
    "corresponding to eigenvector $\\lvert A\\rangle$. It is easy to\n",
    "prove that the eigenvalues of an Hermitean operator are real.\n",
    "\n",
    "\\begin{eqnarray}\n",
    "\\hat{O}\\lvert A\\rangle &=&a\\lvert A\\rangle .   \\\\\n",
    "\\hat{O^{\\dagger }}\\lvert A\\rangle &=& a^{\\ast}\\lvert A\\rangle\n",
    "\\end{eqnarray}\n",
    "\n",
    "Therefore, we have that $\\left(\\hat{O}-\\hat{O}^{\\dagger }\\right) \\lvert A\\rangle =(a-a^{\\ast })\\lvert\n",
    "A\\rangle =0$. thus, $a=a^{\\ast }$.\n",
    "\n",
    "Also, one can prove that eigenvectors of the same Hermitean operator having\n",
    "different eigenvalues are orthogonal.\n",
    "\n",
    "\n",
    "\n",
    "### Tensor product\n",
    "\n",
    "Tensor products of operators in matrix representation are calculated as\n",
    "\n",
    "\n",
    "\\begin{eqnarray}\n",
    "\\hat{A} \\otimes \\hat{B} & = &\\left( \n",
    "\\begin{array}{cccccccc}\n",
    "A_{11}B_{11} & ... & A_{11}B_{1q} & ... & ... & A_{1n}B_{11} & ... & A_{1n}B_{1q}\n",
    "&  \\\\ \n",
    ". & . & . & . & . & . & . & . &  \\\\ \n",
    ". & . & . & . & . & . & . & . &  \\\\ \n",
    "A_{11}B_{p1} & ... & A_{11}B_{pq} & ... & ... & A_{1n}B_{p1} & ... & A_{1n}B_{pq}\n",
    "&  \\\\ \n",
    ". & . & . & . & . & . & . & . &  \\\\ \n",
    ". & . & . & . & . & . & . & . & \\\\ \n",
    "A_{m1}B_{11} & ... & A_{m1}B_{1q} & ... & ... & A_{mn}B_{11} & ... & A_{mn}B_{1q}\n",
    "&  \\\\ \n",
    ". & . & . & . & . & . & . & . & \\\\ \n",
    ". & . & . & . & . & . & . & . &  \\\\ \n",
    "A_{m1}B_{p1} & ... & A_{m1}B_{pq} & ... & ... & A_{mn}B_{p1} & ... & A_{mn}B_{pq}\n",
    "&  \\\\ \n",
    "&  &  &  &  &  &  & \n",
    "\\end{array}\n",
    "\\right)\n",
    "\\end{eqnarray}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exercises\n",
    "\n",
    "\n",
    "<ol>\n",
    "\n",
    "<li>\n",
    "Find the bra (adjoint vector) corresponding to the following kets. Write it both in Dirac's notation and in matrix form\n",
    "\n",
    "<ol>\n",
    "<li>\n",
    "$ \\lvert A \\rangle = \n",
    "        \\begin{pmatrix}\n",
    "        \\frac{i}{\\sqrt{2}} \\\\\n",
    "        0 \\\\\n",
    "        0 \\\\\n",
    "        \\frac{1}{\\sqrt{2}} \n",
    "        \\end{pmatrix} $\n",
    "</li>\n",
    "\n",
    "<li>\n",
    "$ \\lvert B \\rangle = \n",
    "        \\begin{pmatrix}\n",
    "        \\frac{i}{\\sqrt{3}} \\\\\n",
    "        0 \\\\\n",
    "        \\frac{1}{\\sqrt{3}}  \\\\\n",
    "        \\frac{1}{\\sqrt{3}} \n",
    "        \\end{pmatrix} $\n",
    "</li>\n",
    "\n",
    "<li>\n",
    "$ \\lvert C \\rangle = \n",
    "        \\begin{pmatrix}\n",
    "        \\frac{1-i\\sqrt{2}}{\\sqrt{6}} \\\\\n",
    "        \\frac{\\sqrt{3}}{\\sqrt{6}} \\\\\n",
    "        \\frac{1+i\\sqrt{2}}{\\sqrt{6}}  \\\\\n",
    "        0 \n",
    "        \\end{pmatrix} $\n",
    "</li>\n",
    "</ol>\n",
    "</li>\n",
    "\n",
    "<li>\n",
    "Calculate the following scalar products using the kets given above\n",
    "\n",
    "<ol>\n",
    "<li>\n",
    "$ \\langle A \\rvert B \\rangle $\n",
    "</li>\n",
    "\n",
    "<li>\n",
    "$ \\langle B \\rvert C \\rangle $\n",
    "</li>\n",
    "\n",
    "<li>\n",
    "$ \\langle A \\rvert C \\rangle $\n",
    "</li>\n",
    "</ol>\n",
    "</li>\n",
    "\n",
    "<li>\n",
    "Consider a two-dimensional Hilbert space $\\mathcal{H}_2$ with basis vectors:\n",
    "\n",
    "$ \\lvert 0 \\rangle = \\begin{pmatrix}\n",
    "        1 \\\\\n",
    "        0 \n",
    "        \\end{pmatrix} $,\n",
    "        \n",
    "$ \\lvert 1 \\rangle = \\begin{pmatrix}\n",
    "        0 \\\\\n",
    "        1 \n",
    "        \\end{pmatrix} $   \n",
    "        \n",
    "Find a basis for the space $\\mathcal{H}_2 \\otimes \\mathcal{H}_2$ from the basis for $\\mathcal{H}_2$\n",
    "\n",
    "</li>\n",
    "\n",
    "\n",
    "<li> \n",
    "Consider the Pauli $\\hat{Z}$ operator\n",
    "\n",
    "$$ \\hat{Z} = \\lvert 0 \\rangle \\langle 0 \\rvert - \\lvert 1 \\rangle \\langle 1 \\rvert =  \\begin{pmatrix}\n",
    "        1 & 0\\\\\n",
    "        0 & -1\n",
    "        \\end{pmatrix} $$\n",
    "\n",
    "<ol>\n",
    "<li>\n",
    "Calculate the expectation value of $\\hat{Z}$ for a system in the state $\\lvert 0 \\rangle $ and $\\lvert 1 \\rangle $\n",
    "</li>\n",
    "\n",
    "<li>\n",
    " Check if $\\hat{Z}$ is Hermitean\n",
    "</li>\n",
    "</ol>\n",
    "</li>\n",
    "\n",
    "\n",
    "<li> \n",
    "Find the eigenvalues and the eigenstates of $\\hat{Z}$\n",
    "</li>\n",
    "\n",
    "\n",
    "<li> \n",
    "Write the expression of the operator $\\hat{Z} \\otimes \\hat{Z}$ in matrix form\n",
    "</li>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## References\n",
    "\n",
    "[1] P. A. M. Dirac, \"A new notation for quantum mechanics\". Mathematical Proceedings of the Cambridge Philosophical Society. 35 (3): 416–418 (1939). \n",
    "\n",
    "[2] P. A. M. Dirac, The Principles of Quantum Mechanics (1947 Clarendon Press, Oxford).\n",
    "\n",
    "[3] R. P. Feynman, R. B. Leighton, M. Sands, \"The Feynman Lectures on Physics III\". Reading, MA: Addison-Wesley (1965).\n"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
